//
//  UITool.m
//  ITMS
//
//  Created by 中矿科技有限公司 on 16/7/12.
//  Copyright © 2016年 中矿科技有限公司. All rights reserved.
//

#import "UITool.h"

@implementation UITool

+(UIButton *)btnWithTitle:(NSString *)title frame:(CGRect)frame font:(UIFont *)font  unselectColor:(UIColor *)unselectColor backColor:(UIColor *)backColor
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setFrame:frame];
    btn.titleLabel.font=font;
    [btn setBackgroundColor:backColor];
    [btn setTitleColor:unselectColor forState:UIControlStateNormal];
    return btn;
}

+(UILabel *)labelWithTitle:(NSString *)title frame:(CGRect)frame font:(UIFont *)font  textColor:(UIColor *)textColor backColor:(UIColor *)backColor
{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.text = title;
    label.font = font;
    label.textColor = textColor;
    label.backgroundColor =backColor;
    label.textAlignment = NSTextAlignmentCenter;
    return label;
}
+(UIButton *)btnWithBorder:(UIButton *)sender
{
    [sender.layer setMasksToBounds:YES];
    [sender.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
    [sender.layer setBorderWidth:1.0]; //边框宽度
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0, 0, 0, 0.5 });
    
    [sender.layer setBorderColor:colorref];//边框颜色
    CGColorRelease(colorref);
    CGColorSpaceRelease(colorSpace);
    return sender;
}

+ (BOOL) isBlankString:(NSString *)string {
    if (string == nil || string == NULL) {
        return YES;
    }
    if ([string isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    return NO;
}

@end
